# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=libmemcached-awesome
pkgver=1.1.4
pkgrel=2
pkgdesc="C/C++ client library and tools for the memcached server"
arch=('loong64' 'x86_64')
url="https://awesomized.github.io/libmemcached/"
license=('BSD')
depends=('gcc-libs' 'libsasl' 'libevent')
makedepends=('cmake' 'memcached' 'python-sphinx' 'python-sphinx_rtd_theme')
provides=('libmemcached')
conflicts=('libmemcached')
replaces=('libmemcached')
options=('!debug') # some interaction with FIXTURES_OPTIONS_CONFIG makes it
                   # look in the wrong directory (/usr/src/..) for the file
source=(https://github.com/awesomized/libmemcached/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('c477e1f6510e1dc698e84f3717ce690a8f65b94c616ecaa62306cce0f5e3116a')

build() {
  CFLAGS+=' -ffat-lto-objects'
  CXXFLAGS+=' -ffat-lto-objects'

  cmake -B build -S libmemcached-$pkgver \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_DOCS=ON \
    -DBUILD_DOCS_MANGZ=OFF \
    -DBUILD_TESTING=ON \
    -DENABLE_SASL=ON \
    -DENABLE_HASH_HSIEH=ON \
    -DENABLE_HASH_FNV64=ON \
    -DENABLE_HASH_MURMUR=ON \
    -DENABLE_MEMASLAP=ON \
    -DENABLE_OPENSSL_CRYPTO=ON
  cmake --build build
}

check() {
  cd build
  ctest --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 libmemcached-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}

# vim:set ts=2 sw=2 et:
